#_*_coding:utf-8_*_
__author__ = 'alex'
class SchoolMember(object):
    def __init__(self,name,age,sex):
        self.name = name
        self.age = age
        self.sex = sex
    def tell(self):
        print '''--info of %s---
                name:%s
                age :%s
                sex :%s
            '''%(self.name,self.name,self.age,self.sex)
class School(object):
    def __init__(self,name,addr,tel):
        self.school_name = name
        self.addr = addr
        self.tel = tel
        self.__stu_list = []
        self.tech_list = []

class Student(SchoolMember):
    def __init__(self,name,age,sex,grade,school):
        SchoolMember.__init__(self,name,age,sex)
        #School.__init__(self,"Oldboy","Shahe",999)
        super(Student,self).__init__(name,age,sex) #新式类写法
        self.school = school
        self.grade = grade
        self.school._School__stu_list.append(self)


    def pay_money(self):
        print "----%s is paying the tuition fee---" % self.name
    def tell(self):
        SchoolMember.tell(self)
        print '''---from school name :%s
                        class : %s
                        addr:   %s''' % (self.school.school_name,self.grade,self.school.addr)
    def __del__(self):
        print "-0----going to delete my self from stu list"
        #self.school.stu_list.remove(self)
    def transfer(self):
        self.school.stu_list.remove(self)
        self.school = None

class Teacher(SchoolMember):
    def __init__(self,name,age,sex,course,salary,school):
        SchoolMember.__init__(self,name,age,sex )
        self.school = school
        self.course = course
        self.salary = salary
    def teaching(self):
        print "Teacher %s is teaching class of %s" %(self.name,self.course)

school = School("OldBoy","ShaHe",999)
school2 = School("LAMP Brother","HuiLongGuan",110)


s =Student("WangSanjin",33,'M',"PY S10",school)
#print s.school.__stu_list
s22 =Student("WangSijin",34,'M',"PY S10",school)
s3 =Student("WangWujin",35,'M',"PY S10",school)
s2 =Student("LiSong",13,'F',"PY S10",school2)

s.tell()
#s2.tell()


'''
print '-----------------------',len(school.stu_list)
s22.name = "TaoYake"
for s in school.stu_list:
    print s.name,s.school.school_name

s22.transfer()
#print s22.name
print '----------------------without wangsijin-',school.stu_list
for s in school.stu_list:
    print s.name,id(s)
'''

